package day17_Inet.demo02_UDP;

import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class Receive_UDPcopy {
    public static void main(String[] args) throws Exception {
        DatagramSocket ds = new DatagramSocket(8888);
        byte[] bytes = new byte[1024];
        DatagramPacket dp = new DatagramPacket(bytes,bytes.length);
        ds.receive(dp);
        byte[] data = dp.getData();
        System.out.println(new String(data,0,data.length));
        int length = dp.getLength();
        System.out.println(length);
        ds.close();
    }
}
